package nccloud.web.pu.pub.action;

import nccloud.dto.pu.pub.RefBillQueryInfo;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.container.SessionContext;
import nccloud.framework.web.json.JsonFactory;
import nccloud.nc.vo.pub.pf.PullBillInfoVO;
import nccloud.pubitf.riart.businesstype.IPFBusinessTypeService;



public class RefBillQueryAction
  implements ICommonAction
{
  public Object doAction(IRequest request) {
    String str = request.read();
    IJson json = JsonFactory.create();
    RefBillQueryInfo info = (RefBillQueryInfo)json.fromJson(str, RefBillQueryInfo.class);
    
    IPFBusinessTypeService pfservice = (IPFBusinessTypeService)ServiceLocator.find(IPFBusinessTypeService.class);
    PullBillInfoVO[] refbillinfos = null;
    
    try {
      String groupId = SessionContext.getInstance().getClientInfo().getPk_group();
      String userId = SessionContext.getInstance().getClientInfo().getUserid();
      if (info.getIncludeUnCloud()) {
        refbillinfos = pfservice.queryPullBillInfo(info.getBillType(), info
            .getTransType(), groupId, userId, true, true);
      } else {
        refbillinfos = pfservice.getPullBillInfo(info.getBillType(), info
            .getTransType(), groupId, userId);
      }
    } catch (Exception e) {
      ExceptionUtils.wrapException(e);
    } 
    return refbillinfos;
  }
}